#!/usr/bin/env python
#    prop_lanczos_aosoppa
#    -----------------
#    Molecule:         H2O
#    Wave Function:    MP2 (AO-SOPPA)
#    Test Purpose:     Calculation of mean excitation energy through block Lanczos RPA solver

import os
import sys

sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from runtest_dalton import Filter, TestRun

test = TestRun(__file__, sys.argv)

f = Filter()

f.add(string = 'Lanczos Iteration for RPA eigenproblem turned on')

# Lanczos excitation energies
f.add(from_string = 'After Lanczos iteration #',
      to_string = '! Transition strengths in RP_LANCZOS_TRS_STR !',
      abs_tolerance = 1.0e-4)

# Lanczos dipole oscillator strentghs
# hjaaj: disabled this test because it failed for some builds,
#        because of different number of numerical values.
#        The final results are tested below.

#    
#f.add(from_string = '! Oscillator strengths in RP_LANCZOS_OSC_STR !',
#      to_string = 'After Lanczos iteration #',
#      abs_tolerance = 1.0e-3)

# S(0) in Lanczos basis
f.add(from_string = 'S(0) Sum Rule : Dipole Length Approximation in a.u.',
      to_string = 'L(0) Sum Rule : Dipole Length Approximation in a.u.',
      abs_tolerance = 1.0e-3)

# L(0) in Lanczos basis
f.add(from_string = 'L(0) Sum Rule : Dipole Length Approximation in a.u.',
      to_string = 'I(0) Sum Rule : Dipole Length Approximation in eV',
      abs_tolerance = 1.0e-3)

# I(0) in Lanczos basis
f.add(from_string = 'I(0) Sum Rule : Dipole Length Approximation in eV',
      to_string = '|     Memory statistics for AO-SOPPA subroutines      |',
      abs_tolerance = 1.0e-3)

# Static polarizability (from ABACUS)
f.add(from_string = 'Polarizability tensor for frequency     0.000000 au',
      to_string = 'Interatomic separations (in Angstrom):',
      abs_tolerance = 1.0e-3)

test.run(['RPA_lanczos_conv.dal', 'RPA_lanczos_noconv.dal'], ['h2o_augDZ.mol'], f={'out': f},
         accepted_errors=['not implemented for parallel calculations.' ])

sys.exit(test.return_code)
